package com.sxz.sbs.module.staff.presenter;

import com.sxz.sbs.app.App;
import com.sxz.sbs.module.staff.mode.StaffDisposeBean;
import com.sxz.sbs.module.staff.view.StaffDisposeView;
import com.sxz.sbs.rx.RxPresenter;
import com.sxz.sbs.rx.RxSubscriber;
import com.sxz.sbs.rx.RxUtil;

import java.util.HashMap;

/**
 * 员工操作P
 */

public class StaffDisposePresenter extends RxPresenter<StaffDisposeView>{
    /**
     * 根据案场id获取员工
     * @param map
     */
    public void getStaffByPId (HashMap<String,Object> map) {
        addSubscribe(App.getInstance().getApi().getStaffByPid(map)
                .compose(RxUtil.<StaffDisposeBean>handleResult())
                .subscribeWith(new RxSubscriber<StaffDisposeBean>(mView){
                    @Override
                    public void onNext(StaffDisposeBean data) {
                        mView.onGetStaffSuccess(data);
                    }
                })
        );
    }
    /**
     * 案场内调换
     * @param map
     */
    public void staffSwapInner (HashMap<String,Object> map) {
        addSubscribe(App.getInstance().getApi().staffSwapInner(map)
                .compose(RxUtil.<String>handleResult())
                .subscribeWith(new RxSubscriber<String>(mView,true){
                    @Override
                    public void onNext(String data) {
                        mView.onSwapSuccess();
                    }
                })
        );
    }
    /**
     * 案场间调换
     * @param map
     */
    public void staffSwapOut (HashMap<String,Object> map) {
        addSubscribe(App.getInstance().getApi().staffSwapOut(map)
                .compose(RxUtil.<String>handleResult())
                .subscribeWith(new RxSubscriber<String>(mView,true){
                    @Override
                    public void onNext(String data) {
                        mView.onSwapSuccess();
                    }
                })
        );
    }
}
